package com.ethink.platform.controller.order;

import com.ethink.order.api.response.GroupMateDetailResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.order.api.GroupMateFacade;
import com.ethink.order.api.info.GroupMateInfo;
import com.ethink.order.api.request.GroupMateAddRequest;
import com.ethink.order.api.request.GroupMateQueryRequest;
import com.ethink.order.api.request.GroupMateUpdateRequest;

/**
 * 组套商品表 Controller
 *
 * @author default
 * @date 2023-02-22
 */
@Tag(name = "GroupMateController", description = "组套商品表 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/order-service")
public class GroupMateController extends BaseController {

    @Autowired
    private GroupMateFacade groupMateFacade;

    @Operation(summary = "分页查询")
    @GetMapping("/groupMate/query")
    public CommonResponse<List<GroupMateInfo>> queryGroupMate(GroupMateQueryRequest request) {
        return succeedWithPage(groupMateFacade.queryGroupMate(request));
    }

    @Operation(summary = "详情查询")
    @GetMapping("/groupMate/get/{groupMateId}")
    public CommonResponse<GroupMateDetailResponse> getGroupMateById(@PathVariable("groupMateId") Long groupMateId) {
        return succeedWith(groupMateFacade.getGroupMateById(groupMateId));
    }

    @Operation(summary = "查询所有")
    @GetMapping("/groupMate/list")
    public CommonResponse<List<GroupMateInfo>> listGroupMate(GroupMateQueryRequest request) {
        return succeedWith(groupMateFacade.listGroupMate(request));
    }

    @Operation(summary = "新增")
    @PostMapping("/groupMate/add")
    public CommonResponse addGroupMate(@RequestBody GroupMateAddRequest request) {
        groupMateFacade.addGroupMate(request);
        return succeed();
    }

    @Operation(summary = "更新")
    @PutMapping("/groupMate/update")
    public CommonResponse updateGroupMate(@RequestBody GroupMateUpdateRequest request) {
        groupMateFacade.updateGroupMate(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PutMapping("/groupMate/delete/{groupMateId}")
    public CommonResponse deleteGroupMate(@PathVariable("groupMateId") Long groupMateId) {
        groupMateFacade.deleteGroupMate(groupMateId);
        return succeed();
    }

}